home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / bin / metasend (.txt) < prev    next >
Microsoft Windows Help File Content  |  1995-07-02  |  5KB  |  195 lines

  1. # Copyright (c) 1991 Bell Communications Research, Inc. (Bellcore)
  2. # Permission to use, copy, modify, and distribute this material 
  3. # for any purpose and without fee is hereby granted, provided 
  4. # that the above copyright notice and this permission notice 
  5. # appear in all copies, and that the name of Bellcore not be 
  6. # used in advertising or publicity pertaining to this 
  7. # material without the specific, prior written permission 
  8. # of an authorized representative of Bellcore.  BELLCORE 
  9. # MAKES NO REPRESENTATIONS ABOUT THE ACCURACY OR SUITABILITY 
  10. # OF THIS MATERIAL FOR ANY PURPOSE.  IT IS PROVIDED "AS IS", 
  11. # WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
  12. # Conversion from C shell to Bourne shell by Z-Code Software Corp.
  13. # Conversion Copyright (c) 1992 Z-Code Software Corp.
  14. # Permission to use, copy, modify, and distribute this material
  15. # for any purpose and without fee is hereby granted, provided
  16. # that the above copyright notice and this permission notice
  17. # appear in all copies, and that the name of Z-Code Software not
  18. # be used in advertising or publicity pertaining to this
  19. # material without the specific, prior written permission
  20. # of an authorized representative of Z-Code.  Z-CODE SOFTWARE
  21. # MAKES NO REPRESENTATIONS ABOUT THE ACCURACY OR SUITABILITY
  22. # OF THIS MATERIAL FOR ANY PURPOSE.  IT IS PROVIDED "AS IS",
  23. # WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
  24. if [ -z "$METAMAIL_TMPDIR" ]
  25. then METAMAIL_TMPDIR=/tmp
  26. MustDelete=0
  27. batchmode=0
  28. splitsize=100000
  29. while test ! -z "$*"
  30.     case $1 in
  31.         -S) shift
  32.             if test -z "$*"
  33.             then
  34.             echo "-S requires a following argument, the SPLIT threshhold"
  35.             exit 1
  36.             fi
  37.             splitsize=$1
  38.             shift ;;
  39.         -b) batchmode=1
  40.             shift ;;
  41.         -c) shift
  42.             if test -z "$*"
  43.             then
  44.                 echo "-c requires a following argument, the CC address"
  45.             exit 1
  46.             fi
  47.             cc=$1
  48.             shift ;;
  49.         -s) shift
  50.             if test -z "$*"
  51.             then
  52.             echo "-s requires a following argument, the SUBJECT"
  53.             exit 1
  54.             fi
  55.             subject=$1
  56.             shift ;;
  57.         -t) shift
  58.             if test -z "$*"
  59.             then
  60.             echo "-t requires a following argument, the TO address"
  61.             exit 1
  62.             fi
  63.             to=$1
  64.             shift ;;
  65.         -e) shift
  66.             if test -z "$*"
  67.             then
  68.             echo "-e requires a following argument, the ENCODING value"
  69.             exit 1
  70.             fi
  71.             encode=$1
  72.             shift ;;
  73.         -f) shift
  74.             if test -z "$*"
  75.             then
  76.             echo "-f requires a following argument, the DATA FILE"
  77.             exit 1
  78.             fi
  79.             datafile=$1
  80.             shift ;;
  81.         -m) shift
  82.             if test -z "$*"
  83.             then
  84.             echo "-m requires a following argument, the MIME CONTENT-TYPE"
  85.             exit 1
  86.             fi
  87.             ctype=$1
  88.             shift ;;
  89.         -z) MustDelete=1
  90.             shift ;;
  91.         *) echo UNRECOGNIZED METASEND OPTION: $1
  92.            exit 1 ;;
  93.     esac
  94. if test $batchmode -eq 0
  95.     if test -z "${to:-}"
  96.     then
  97.         echo-n "To: "
  98.         read to
  99.     if test -z "${subject:-}"
  100.     then
  101.             echo-n "Subject: "
  102.         read subject
  103.     if test -z "${cc:-}"
  104.     then
  105.         echo-n "CC: "
  106.         read cc
  107.     if test -z "${ctype:-}"
  108.     then
  109.             echo-n "Content-type: "
  110.         read ctype
  111.     if test -z "${datafile:-}"
  112.     then
  113.         looping=1
  114.         while test $looping -eq 1
  115.             echo-n "Name of file containing $ctype data: "
  116.             read datafile
  117.             if test -r "$datafile"
  118.             then
  119.                 looping=0
  120.             else
  121.                 echo "The file $datafile does not exist."
  122.             fi
  123.         done
  124.     if test -z "${encode:-}"
  125.     then
  126.         looping=1
  127.         while test $looping -eq 1
  128.             echo "Do you want to encode this data for sending through the mail?"
  129.             echo "  1 -- No, it is already in 7 bit ASCII"
  130.             echo "  2 -- Yes, encode in base64 (most efficient)"
  131.             echo "  3 -- Yes, encode in quoted-printable (less efficient, more readable)"
  132.             echo "  4 -- Yes, encode it using uuencode (not standard, being phased out)"
  133.             read encode
  134.             looping=0
  135.             case "$encode" in
  136.                 1) encodingprog=cat
  137.                    encode=7bit ;;
  138.                 2) encodingprog="mimencode -b"
  139.                    encode=base64 ;;
  140.                 3) encodingprog="mimencode -q"
  141.                    encode=quoted-printable ;;
  142.                 4) encodingprog="uuencode $datafile"
  143.                    encode=x-uue ;;
  144.                 *) echo Unrecognized answer, please try again.
  145.                    looping=1 ;;
  146.             esac
  147.         done
  148.     if test -z "${to:-}" \
  149.         -o -z "${subject:-}" \
  150.         -o -z "${ctype:-}" \
  151.         -o -z "${datafile:-}"
  152.     then
  153.         echo "metasend: in batch mode, -t, -s, -f, and -m are all required"
  154.         exit 1
  155.     if test ! -r "$datafile"
  156.     then
  157.         echo "metasend: The file $datafile does not exist"
  158.         exit 1
  159.     if test -z "${cc:-}"
  160.     then
  161.         cc=''
  162.     if test -z "${encode:-}"
  163.     then
  164.         case "$ctype" in
  165.             text*) encodingprog="mimencode -q"
  166.                    encode=quoted-printable ;;
  167.             *) encodingprog="mimencode -b"
  168.                encode=base64 ;;
  169.         esac
  170.     else
  171.         case "$encode" in
  172.             base64) encodingprog="mimencode -b" ;;
  173.             x-uue) encodingprog="uuencode $datafile" ;;
  174.             *) encodingprog="mimencode -q"
  175.                encode=quoted-printable ;;
  176.         esac
  177. fname=$METAMAIL_TMPDIR/metasend.$$
  178. echo "To: $to" > $fname
  179. echo "Subject: $subject" >> $fname
  180. echo "CC: $cc" >> $fname
  181. echo "MIME-Version: 1.0" >> $fname
  182. echo "Content-type: $ctype" >> $fname
  183. echo "Content-Transfer-Encoding: $encode" >> $fname
  184. echo "" >> $fname
  185. "$encodingprog" < "$datafile" >> "$fname"
  186. # Ensure last line has trailing carriage return
  187. echo "" >> "$fname"
  188. splitmail -s $splitsize -d $fname
  189. if test $? -eq 0
  190.     rm -f $fname
  191. elif test "$MustDelete" -eq 1
  192.     echo Mail delivery failed
  193.     rm -f $fname
  194.     echo "Mail delivery failed, draft mail is in $fname"
  195.